<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2019/5/10
 * Time: 16:31
 */
header("Content-Type:application/json;charset=utf-8");
header("Access-Control-Allow-Origin:*");
include "dbhealper.php";

if($_SERVER["REQUEST_METHOD"]=="POST"){
    $UNAME=$_POST["uname"];
    $UPWD=$_POST["upwdo"];

    $sql="INSERT INTO `userinfo` (`u_name`,`u_pwd`) VALUES ('".$UNAME."','".$UPWD."')";
    $result=dbhealper($sql);//postman进行测试,看看能不能得到数据;postman里面的key值是uname(和html一致)

    if($result>=1){
        $arr=Array("msg"=>"注册成功","status"=>1);
        //要通过json_encode()进行转换 否则在html中打印交互数据res的时候打印不出来
        print_r(json_encode($arr));
    }else{
        $arr=Array("msg"=>"注册失败","status"=>-1);
        print_r(json_encode($arr));
}
}else{
    $arr=Array("msg"=>"不支持get请求","status"=>0);
    print_r(json_encode($arr));
}